<div class="table-content">
	<div class="layui-form-bar border-t border-x">
		<button class="layui-btn layui-btn-sm add-new">+ 新建任务</button>
	</div>
	<table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script>
function pageInit(){
	var project_id = {$id};
	var table = layui.table,tool = layui.tool;	
	layui.taskTable = table.render({
		elem: '#test',
		title: '任务列表',
		cellMinWidth:200,
		url: "/task/index/index",
		where:{'project_id':project_id},
		page: true, //开启分页
		limit: 20,
		cols:  [[
			{field:'id', title: '任务编号',width: 80, align:'center',fixed:'left'}
			,{field:'flow_name',title: '状态',align:'center',width: 80,templet:function(d){
				var html = '<span class="layui-badge bg-flow-'+d.flow_status+'">'+d.flow_name+'</span>';
				return html;
			}}
			,{field:'type_name',title: '类型',width: 60,align:'center',templet:function(d){
				var html = '<span class="color-status-'+d.type+'">'+d.type_name+'</span>';
				return html;
			}}
			,{field:'title',title: '任务主题',rowspan: 2,templet:function(d){
				var html = '<span class="layui-badge bg-priority-'+d.priority+'">'+d.priority_name+'</span> <a class="open-a" data-href="/task/index/view/id/'+d.id+'">'+d.title+'</a>';
				return html;
			}}
			,{field:'director_name',title: '负责人', align:'center',width: 80}
			,{field:'assist_admin_names',title: '协作人',width: 160}
			,{field:'plan_hours',title: '预估工时', align:'center',width: 80}				
			,{field:'end_time',title: '预计结束日期', width: 150,templet:function(d){
				var html = d.end_time;	
				if(d.delay>0){
					html+= '<span class="color-status-0 ml-1" style="font-size:12px;">逾期'+d.delay+'天</span>';	
				}			
				return html;
			}}
		]]
	});
	
	//新增
	$('.add-new').on('click',function(){
		tool.open('/task/index/add?project_id='+project_id);
	});
}		
</script>